package com.jzo2o.foundations.controller.consumer;

import com.jzo2o.api.foundations.dto.response.RegionSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeAggregationSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeAggregationTypeSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeCategoryResDTO;
import com.jzo2o.foundations.model.dto.response.ServeSimpleResDTO;
import com.jzo2o.foundations.service.HomeService;
import com.jzo2o.foundations.service.IServeService;
import com.jzo2o.foundations.service.ServeAggregationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author DarkClown
 * @date 2024-08-21 20:06
 * @project_name jzo2o-foundations
 * @parem
 **/
@RestController("consumerServeController")
@RequestMapping("/customer/serve")
@Api(tags = "用户端 - 首页服务")
public class ServeController {

    @Resource
    private IServeService serveService;

    @Autowired
    private HomeService homeService;

    @Autowired
    private ServeAggregationService serveAggregationService;


    @GetMapping("/firstPageServeList")
    @ApiOperation("首页服务列表实现")
    public List<ServeCategoryResDTO> firstPageServeList(@RequestParam("regionId") Long regionId) {
        return serveService.firstPageServeList(regionId);
    }

    @GetMapping("/hotServeList")
    @ApiOperation("首页热门服务列表")
    public List<ServeAggregationSimpleResDTO> listHotServe(@RequestParam("regionId") Long regionId) {
        return homeService.findHotServeListByRegionIdCache(regionId);
    }

    @GetMapping("/serveTypeList")
    @ApiOperation("服务分类列表")
    public List<ServeAggregationTypeSimpleResDTO> serveTypeList(@RequestParam("regionId") Long regionId) {
        return homeService.serveTypeList(regionId);
    }

    @GetMapping("/{id}")
    @ApiOperation("服务详情")
    public ServeAggregationSimpleResDTO selectById(@PathVariable("id") Long id) {
        return homeService.selectById(id);
    }

    @GetMapping("/search")
    @ApiOperation("全部服务列表")
    public List<ServeSimpleResDTO> findServeList(@RequestParam("cityCode") String cityCode,@RequestParam(value = "serveTypeId",required = false) Long serveTypeId,@RequestParam(value = "keyword",required = false)String keyword) { 
        return serveAggregationService.findServeList(cityCode,serveTypeId,keyword);
    }

}
